#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QDialog>
#include <QThread>
#include<QTimer>
#include<QLabel>
#include<QVBoxLayout>
#include <QGuiApplication>
#include <QScreen>
#include <QRect>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    QRect desktopRect = QGuiApplication::primaryScreen()->geometry();
    this->setAttribute(Qt::WA_DontShowOnScreen, true);
    ui->setupUi(this);
    QTimer* timer = new QTimer(this);
    int desktopWidth = desktopRect.width();
    int desktopHeight = desktopRect.height();
    connect(timer, &QTimer::timeout, this, [=]() {
        if (dialogCount < 1000) {
            int x = rand() % desktopWidth;
            int y = rand() % desktopHeight;
            QDialog* dig = new QDialog(this);
            dig->setWindowIcon(QIcon(":/1.png"));
            dig->setWindowTitle("温馨提示");
            QLabel*label=new QLabel(great[dialogCount%11],dig);

            label->setStyleSheet("color: black; font-size: 28px;font-weight: bold;");
            label->setAlignment(Qt::AlignCenter);


            QVBoxLayout* layout = new QVBoxLayout(dig);
            layout->addWidget(label);
            dig->setLayout(layout);
            dig->move(x, y);
            dig->resize(400, 100);
            dig->setStyleSheet("QDialog { background-color:"+color[dialogCount%7]+"; }");

            dig->show();
            dialogCount++;
        } else {
            timer->stop(); // 完成后停止定时器
        }
    });
    timer->start(100); // 1秒触发一次
}

MainWindow::~MainWindow()
{
    delete ui;
}

